import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
import { getInterviewTitle } from "@/api/interview";

export const getInterviewTitleAsync = createAsyncThunk(
  "interview/getInterviewTitleAsync",
  async (_, thunkAPI) => {
    const { data } = await getInterviewTitle();
    thunkAPI.dispatch(initialInterviewList(data));
  }
);

const interviewSlice = createSlice({
  name: "interview",
  initialState: {
    interviewList: [],
  },
  reducers: {
    initialInterviewList: (state, { payload }) => {
      state.interviewList = payload;
    },
  },
});

const { initialInterviewList } = interviewSlice.actions;
export default interviewSlice.reducer;
